/**
 * characterLinksOptions.js
 * Copyright (C) 2008-2011 Tommi Rautava
 * 
 * This file is part of Popmungo.
 *
 * Popmungo is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Popmungo is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

org.mozdev.popmungo.CharacterLinksOptions = {
	
	onLoad: function characterLinksOptionsOnLoad() {
		try {
			this.characterPopupLinksFeaturesOnCommand();
			this.characterVisibleLinksFeaturesOnCommand();
		}
		catch (err) {
			org.mozdev.popmungo.logger.logError(err);
		}
		
		return true;
	},
	
	
	characterPopupLinksFeaturesOnCommand:
		function characterPopupLinksFeaturesOnCommand() {
			var cb = window.document.getElementById('links.popup.character.enabled.checkbox');
			var disabled = !cb.checked || cb.disabled;
			
			window.document.getElementById('links.popup.character.call.enabled.checkbox').disabled = disabled;
			window.document.getElementById('links.popup.character.sendMessage.enabled.checkbox').disabled = disabled;
			
			return true;
		},


	characterVisibleLinksFeaturesOnCommand:
	function characterVisibleLinksFeaturesOnCommand() {
		var cb = window.document.getElementById('links.visible.character.enabled.checkbox');
		var disabled = !cb.checked || cb.disabled;
		
		window.document.getElementById('links.visible.character.call.enabled.checkbox').disabled = disabled;
		window.document.getElementById('links.visible.character.sendMessage.enabled.checkbox').disabled = disabled;
		window.document.getElementById('links.visible.character.type.radiogroup').disabled = disabled;
		
		this.visibleLinksTypeOnCommand();
		
		return true;
	},


	visibleLinksTypeOnCommand:
	function visibleLinksTypeOnCommand() {
		var rg = window.document.getElementById('links.visible.character.type.radiogroup');
		var disabled = (rg.value != 1) || rg.disabled;
		
		window.document.getElementById('links.visible.character.type.textColor.colorpicker').disabled = disabled;
		window.document.getElementById('links.visible.character.type.textColor.colorpicker.label').disabled = disabled;
		window.document.getElementById('links.visible.character.type.backgroundColor.colorpicker').disabled = disabled;
		window.document.getElementById('links.visible.character.type.backgroundColor.colorpicker.label').disabled = disabled;
		
		return true;
	}
	
};

org.mozdev.popmungo.logger.log("org.mozdev.popmungo.CharacterLinksOptions loaded");

// EOF